package com.yami.shop.bean.enums;

import java.util.Objects;

/**
 * 分账订单状态
 * @author Yami
 */
public enum DivideStatus {
    /**
     * 创建订单
     */
    CREATE(1, "创建订单"),

    /**
     * 待确认
     */
    CONFIRM(2, "待确认"),

    /**
     * 成功
     */
    SUCCESS(3, "成功"),
    /**
     * 失败
     */
    FAIL(4, "失败")
    ;

    private final Integer num;
    private final String name;

    public Integer value() {
        return num;
    }

    DivideStatus(Integer num, String name) {
        this.num = num;
        this.name = name;
    }

    public static DivideStatus instance(Integer value) {
        DivideStatus[] enums = values();
        for (DivideStatus statusEnum : enums) {
            if (statusEnum.value().equals(value)) {
                return statusEnum;
            }
        }
        return null;
    }


    public static String getStatusName(Integer value) {
        DivideStatus divideStatus = instance(value);
        if (Objects.isNull(divideStatus)) {
            return null;
        }
        return divideStatus.name;
    }
}
